package com.yehongyu.mytools.basic.grammar;

public class Java003_StringDetail {

	public static void main(String[] args) {
		// 测试String类的对象值。""这个是常量，在栈内存中共享，new String()是新建对象，分配在堆内存中。
		String s1 = "123";
		String s2 = "123";
		String s3 = new String("123");
		String s4 = new String("123");

		System.out.println("s1 == s2 : " + (s1 == s2));
		System.out.println("s1 == s3 : " + (s1 == s3));
		System.out.println("s3 == s4 : " + (s1 == s4));
		System.out.println("s1.equals(s2) = " + s1.equals(s2));
		System.out.println("s1.equals(s3) = " + s1.equals(s3));
		System.out.println("s3.equals(s4) = " + s3.equals(s4));
	}
}
